﻿using Monti.MVVM;

namespace Peter.Data.Options
{
   /// <summary>
   /// Options for the editors.
   /// </summary>
   public class EditorOptions : ViewModelBase
   {
      #region Fields

      private int m_IndentSize;
      private bool m_ShowLineNumbers;
      private bool m_WrapText;
      private bool m_EnableEmails;
      private bool m_EnableHyperlinks;
      private bool m_ShowTabs;
      private bool m_ShowSpaces;
      private bool m_ShowEol;
      private bool m_ConvertTabsToSpaces;
      private bool m_AllowScrollPastDocument;
      private bool m_HoldCtrlForHyperlinks;

      #endregion

      #region Setup

      /// <summary>
      /// Intializes a new global editor properties object.
      /// </summary>
      public EditorOptions () 
      { 
         this.SetDefaults ();
      }

      /// <summary>
      /// Sets the default properties.
      /// </summary>
      public void SetDefaults ()
      {
         this.ShowLineNumbers = true;
         this.WrapText = false;
         this.EnableEmails = false;
         this.EnableHyperlinks = false;
         this.ShowTabs = false;
         this.ShowSpaces = false;
         this.ShowEol = false;
         this.IndentSize = 3;
         this.ConvertTabsToSpaces = true;
         this.AllowScrollPastDocument = true;
         this.HoldCtrlForHyperlinks = true;
      }

      #endregion

      #region Properties

      /// <summary>
      /// Gets or Sets if the editors should show line numbers or not.
      /// </summary>
      public bool ShowLineNumbers 
      {
         get { return this.m_ShowLineNumbers; }
         set
         {
            this.m_ShowLineNumbers = value;
            this.RaisePropertyChanged ("ShowLineNumbers");
         }
      }

      /// <summary>
      /// Gets or Sets if the editors should word wrap or not.
      /// </summary>
      public bool WrapText
      {
         get { return this.m_WrapText; }
         set
         {
            this.m_WrapText = value;
            this.RaisePropertyChanged ("WrapText");
         }
      }

      /// <summary>
      /// Gets or Sets if ctrl should be held to follow hyperlinks or not.
      /// </summary>
      public bool HoldCtrlForHyperlinks
      {
         get { return this.m_HoldCtrlForHyperlinks; }
         set
         {
            this.m_HoldCtrlForHyperlinks = value;
            this.RaisePropertyChanged ("HoldCtrlForHyperlinks");
         }
      }

      /// <summary>
      /// Gets or Sets if the editor is allowed to scroll past the end of the doucment or not.
      /// </summary>
      public bool AllowScrollPastDocument
      {
         get { return this.m_AllowScrollPastDocument; }
         set
         {
            this.m_AllowScrollPastDocument = value;
            this.RaisePropertyChanged ("AllowScrollPastDocument");
         }
      }

      /// <summary>
      /// Gets or Sets if the editors should convert tabs to spaces or not.
      /// </summary>
      public bool ConvertTabsToSpaces
      {
         get { return this.m_ConvertTabsToSpaces; }
         set
         {
            this.m_ConvertTabsToSpaces = value;
            this.RaisePropertyChanged ("ConvertTabsToSpaces");
         }
      }

      /// <summary>
      /// Gets or Sets the editors indention size.
      /// </summary>
      public int IndentSize
      {
         get { return this.m_IndentSize; }
         set
         {
            this.m_IndentSize = value;
            this.RaisePropertyChanged ("IndentSize");
         }
      }

      /// <summary>
      /// Gets or Sets if the editors should show end of line symbols or not.
      /// </summary>
      public bool ShowEol
      {
         get { return this.m_ShowEol; }
         set
         {
            this.m_ShowEol = value;
            this.RaisePropertyChanged ("ShowEOL");
         }
      }

      /// <summary>
      /// Gets or Sets if the editors should show space symbols or not.
      /// </summary>
      public bool ShowSpaces
      {
         get { return this.m_ShowSpaces; }
         set
         {
            this.m_ShowSpaces = value;
            this.RaisePropertyChanged ("ShowSpaces");
         }
      }

      /// <summary>
      /// Gets or Sets if the editors should show tab symbols or not.
      /// </summary>
      public bool ShowTabs
      {
         get { return this.m_ShowTabs; }
         set
         {
            this.m_ShowTabs = value;
            this.RaisePropertyChanged ("ShowTabs");
         }
      }

      /// <summary>
      /// Gets or Sets if the editors should highlight hyperlinks or not.
      /// </summary>
      public bool EnableHyperlinks
      {
         get { return this.m_EnableHyperlinks; }
         set
         {
            this.m_EnableHyperlinks = value;
            this.RaisePropertyChanged ("EnableHyperlinks");
         }
      }

      /// <summary>
      /// Gets or Sets if the editors should highlight emails or not.
      /// </summary>
      public bool EnableEmails
      {
         get { return this.m_EnableEmails; }
         set
         {
            this.m_EnableEmails = value;
            this.RaisePropertyChanged ("EnableEmails");
         }
      }

      #endregion
   }
}
